package tests.create;

import static org.junit.Assert.*;

import model.Budget;
import model.BudgetFactory;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/*
 * 
 * Attempts to create 10 basic budgets
 * 
 */

public class BudgetCreateTest01
{
	Budget budget;
	BudgetFactory factory;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception
	{
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception
	{
	}

	@Before
	public void setUp() throws Exception
	{
	}

	@After
	public void tearDown() throws Exception
	{
	}

	@Test
	public void test()
	{
		factory = new BudgetFactory();
        
        try
        {
        	for(int i = 1; i <= 10; i++)
        	{
        		//Create a budget
        		budget = (Budget) factory.create();
        		budget.setName("Test budget "+i);
           
        		budget.setDescription("This is a test budget.");
            
        		Boolean successful = budget.commit();
        		if(!successful)
        		{
        			fail("Creating Budget failed");
        		}
        		else{
        			//Helper.delete(budget, WorkletContext.getInstance());
        		}
        	}
        }
        catch(Exception e)
        {
            fail("Creating Budget failed with exception: " + e);
        }
        
        System.out.println("Budgets commited. BudgetCreateTest01.java passed.");
	}
}